package com.fast.develop.dm.configuration.properties;

import com.fast.develop.dm.core.properties.DomainRuntimeProperties;
import com.fasterxml.jackson.annotation.JsonCreator;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

/**
 * @author 莫寅
 * @createTime 2022-06-06 11:34
 * @desc：
 */
@ConfigurationProperties(prefix = "fast.develop.domain")
public class DomainModelPropesties {

    @NestedConfigurationProperty
    private DomainRuntimeProperties api = new DomainRuntimeProperties();

    private String[] packagesToScan;

    private Class[] annotatedClasses;

    private String[] mappingResources;

    private boolean showSql = false;

    private DdlAuto ddlAuto;

    public DomainRuntimeProperties getRuntime() {
        return api;
    }

    public void setRuntime(DomainRuntimeProperties runtime) {
        this.api = runtime;
    }

    public String[] getPackagesToScan() {
        return packagesToScan;
    }

    public void setPackagesToScan(String[] packagesToScan) {
        this.packagesToScan = packagesToScan;
    }

    public Class[] getAnnotatedClasses() {
        return annotatedClasses;
    }

    public void setAnnotatedClasses(Class[] annotatedClasses) {
        this.annotatedClasses = annotatedClasses;
    }

    public String[] getMappingResources() {
        return mappingResources;
    }

    public void setMappingResources(String[] mappingResources) {
        this.mappingResources = mappingResources;
    }

    public boolean isShowSql() {
        return showSql;
    }

    public void setShowSql(boolean showSql) {
        this.showSql = showSql;
    }

    public DdlAuto getDdlAuto() {
        return ddlAuto;
    }

    public void setDdlAuto(DdlAuto ddlAuto) {
        this.ddlAuto = ddlAuto;
    }


    public enum DdlAuto {
        CREATE("create", "每次运行该程序，没有表格会新建表格，表内有数据会清空"),
        CREATE_DROP("create-drop", "每次程序结束的时候会清空表"),
        UPDATE("update", "每次运行程序，没有表格会新建表格，表内有数据不会清空，只会更新"),
        VALIDATE("validate", "运行程序会校验数据与数据库的字段类型是否相同，不同会报错");


        private String value;

        private String display;

        DdlAuto(String value, String display) {
            this.value = value;
            this.display = display;
        }

        @JsonCreator
        public static DdlAuto create(Object name) {
            return DdlAuto.create(name);
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getDisplay() {
            return display;
        }

        public void setDisplay(String display) {
            this.display = display;
        }
    }
}
